<%@ page pageEncoding='UTF-8'%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<s:set var="contextPath" value="#request.get('javax.servlet.forward.context_path')" scope="request" />

<div id="common-patient-list-container" class="list-container">
	<%-- search-form-container --%>
	<div id="patient-search-form-container" class="panel collapsed" data-role="panel">
		<div class="panel-header">Search Patients</div>
		<div class="panel-content" style="display: none;">
			<form id="patient-search-form" class="search-form patient-search" action="${patientSearchFormActionUrl}" method="get">
				<fieldset>
    				<label>Name</label>
    				<div class="input-control text">
        				<input type="text" name="term" value="" placeholder="search text"/>
        				<button type="submit" class="btn-search"></button>
    				</div>
    				<div class="input-control radio">
    					Order by:
    					<div class="input-control radio margin10 default-style" data-role="input-control">
	    					<label>
	    						<input type="radio" name="sort" value="name" checked="checked"/>
	    						<span class="check"></span>
								Name
							</label>
						</div>
						<div class="input-control radio margin10 default-style" data-role="input-control">
							<label>
								<input type="radio" name="sort" value="dob"/>
								<span class="check"></span>
	                			Date of Birth
	                		</label>
	                	</div>
                	</div>
	                <div class="btn-control">
	                	<input type="submit" value="Search" />
	                </div>
            	</fieldset>
        	</form>
    	</div>
	</div>
	<div class="count-container">
		<h2 class="item-title fg-green place-left">Found ${guiPagination.totalCount} Items</h2>
	</div>
	<br clear="all"/>
	<s:if test="%{termExist || sortExist}">
	 	<div id="search-info-container"> 
			search <em class="fg-darkOrange">${term}</em>
			ordered by <em class="fg-darkGreen">${sort.label}</em>          
		</div>
	</s:if>
	<br clear="all"/>
	
	<div class="listview-outlook">
		<s:iterator var="oGuiPatient" value="%{guiPatientList}">
			<span class="list">
				<div class="list-content list-container">
					<div class="list-icon-container place-left">
	   					<s:if test="%{#oGuiPatient.male}">
							<img class="list-icon bg-lightBlue" src="${contextPath}/img/icon/Man-128.png"/>
						</s:if>
						<s:elseif test="%{#oGuiPatient.female}">
							<img class="list-icon bg-lightPink" src="${contextPath}/img/icon/Woman-128.png"/>
						</s:elseif>
					</div>
		           	<div class="place-left">
		               	<span class="list-title">
							<a href="${contextPath}/patient/show?id=${oGuiPatient.userId}">
								${oGuiPatient.name}
							</a>
		               	</span>
						<span class="list-subtitle">Date Of Birth: ${oGuiPatient.dobString}</span>
						<span class="list-remark">${oGuiPatient.gender}</span>
					</div>
					<div class="btn-container place-right">
						<s:if test="%{#view == 'PrescriptionList'}">
							<s:if test="%{#oGuiPatient.existGuiPrescription}">
								<a href="${contextPath}/prescription/registration?rootPrescriptionId=${oGuiPatient.guiPrescription.prescriptionId}">
									<i class="icon-file-4 bg-lightBlue fg-white" data-hint="Continue|Create by continuing past"></i>
								</a>
							</s:if>
							<a href="${contextPath}/prescription/registration?patientId=${oGuiPatient.userId}">
								<i class="icon-file-3 bg-lightBlue fg-white" data-hint="New|Create new"></i>
							</a>
						</s:if>
					</div>
	                <br clear="all"/>
				</div>
			</span>
		</s:iterator>
 	</div>
 
	<div class="pagination no-print">           	
		<ul>
	    	<li class="first ${guiPagination.activePage == guiPagination.firstPage ? 'disabled' : ''}">
				<a href="${patientSearchFormActionUrl}?page=${guiPagination.firstPage}"><i class="icon-first-2"></i></a>
			</li>
			<li class="prev ${guiPagination.activePage == guiPagination.firstPage ? 'disabled' : ''}">
				<a href="${patientSearchFormActionUrl}?page=${guiPagination.prevPage}"><i class="icon-previous"></i></a>
			</li>
			<s:iterator status="stat" begin="1" end="%{guiPagination.noOfPages}">
				<li class="${guiPagination.activePage == stat.count ? 'active' : ''}">
					<a href="${patientSearchFormActionUrl}?page=${stat.count}">${stat.count}</a>
				</li>
			</s:iterator>         
			<li class="next ${guiPagination.activePage == guiPagination.lastPage ? 'disabled' : ''}">
				<a href="${patientSearchFormActionUrl}?page=${guiPagination.nextPage}"><i class="icon-next"></i></a>
			</li>
			<li class="last ${guiPagination.activePage == guiPagination.lastPage ? 'disabled' : ''}">
				<a href="${patientSearchFormActionUrl}?page=${guiPagination.lastPage}"><i class="icon-last-2"></i></a>
            </li>
        </ul>
    </div>
    
</div>